<?php
header('Content-type:text/html;charset=utf-8');
@ob_start();
@ob_start('ob_gzip');
@date_default_timezone_set('PRC');
@set_time_limit (60);
@session_start();
@error_reporting(0);
ini_set("display_errors","Off");
ini_set('memory_limit','64M');
ini_set('upload_max_filesize','25M');
ini_set('post_max_size','25M');
ini_set('max_input_time','600');
$time=time();
$time_jt=strtotime(date("Y-m-d 00:00:00"));
$time_mt=strtotime(date("Y-m-d 00:00:00",strtotime("+1 day")));
$time_date=date("Y-m-d");
$time_now =date("Y-m-d H:i:s");
if (!file_exists('config/install.lock')){
    echo '<meta http-equiv=refresh content="0;url=install/index.php?">
          <script>location.href="install/index.php?"</script>';
}
define('BZ_XTBLOG', TRUE);          //系统文件
define('BZ_WJSCUZ', TRUE);          //系统文件
define('BZ_plugin', TRUE);          //系统插件
define('MBLOG_ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR);
$url_a=$_SERVER['HTTP_REFERER'];
$url_b=$_SERVER['REQUEST_URI'];
$self = basename($_SERVER['PHP_SELF']);
$httpurl=''.$_SERVER['SERVER_NAME'].'';
$agent=$_SERVER['HTTP_USER_AGENT'];//访问游览器信息
$ip   =$_SERVER['REMOTE_ADDR'];
$serverip=GetHostByName($_SERVER['SERVER_NAME']);
$url='http://'.$_SERVER['SERVER_NAME'];
$Bingz_url='http://'.$_SERVER['SERVER_NAME'].'/';
$Bingz_url_upgrade='http://k7t.cn/upgrade2/';
$Bingz_url_addon  ='http://k7t.cn/index.php?m=addon&';
##########################系统信息 
$bzxtname ='槟榔Ⅱ';
$bzxtnamey='Bingz';
$bzxtvbb  ='3.4';
$bzxtvsj  ='2015-08-10';
$wzxx_name='系统';
###########################
require ('config/conn.php');
require ('config/config.php');
require ('include/mysql.class.php');
function is_url($str){
         return preg_match("/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\’:+!]*([^<>\"])*$/", $str);
}
if(!$url_b or $url_b == '/'){
if($url=$db->get_one('url',"`type` = '1' and  `url` = '$httpurl' ",'content')){
    $db->update('url',array('fwsl' => '+1' ), "`id`= '$url[id]' ");
  if(is_url($url[content])){
    Header("Location:$url[content]"); 
  }else{
    $config_index=explode('&',$url[content]);
    foreach( $config_index as $a=> $val){
             $valmh=explode('=',$val);
             if(strpos($valmh[0],'?')){
             	$valvf=explode('?',$valmh[0]);
     	        $valmh[0]=$valvf[1];
             }
             $_GET[$valmh[0]]=$valmh[1];
    }
  }
}
}
$flmmc=$_GET[$Bingz_ml];
$fwjmc=$_GET[$Bingz_md];
$Bingz_images_height=Bingz_config('upload_config_tpheight');//强制上传图片宽度的像素数(缩小)0不设置
$Bingz_images_width=Bingz_config('upload_config_tpwidth');  //强制上传图片高度的像素数(缩小)0不设置
$tplrefresh =Bingz_config('system_config_templatessj');     //模板刷新
$Bingz_cache=Bingz_config('system_config_cache');           //数据缓存时间 秒
$Bingz_contentgl=Bingz_config('system_config_contentgl');	  //内容过滤 用,隔开
$Bingz_gzip =Bingz_config('system_config_gzip');            //是否采用 Gzip 压缩输出
require ('include/class.php');
require ('include/user.class.php');
require ('include/forum.class.php');
$templates=$db->get_one('templates',"`id` = '1' ",'id');
##############################
if($_COOKIE['user_login']){
    $user=$db->get_one('user'," `pwss` = '$_COOKIE[user_login]' and  `ip` = '$_COOKIE[user_ip]'",'');
}
if($user){
    if($user[time_a] < $time_jt && Bingz_config('user_config_dnusz') == '1'){
       Bingz_management($user['uid'],Bingz_config('user_config_dnulx'),'+'.Bingz_config('user_config_dnuse').'','每天第一次登陆奖励！','','','','','','','','1');
    }
    $timeag=$time+60;
    $db->update('user',"`user_zx` = '5',`time_a` = '$timeag'", "`uid`= '$user[uid]' ");
  if($db->get_one('user_qxz',"`id` ='$user[user_qx]' and `qxid` = '10'" ,'')){
     $wzglqx='10';
     $wzadming='<a href="admin.php?dmp='.$Bingz_adminm.'" target="_blank" ><b><font color="#ff0000">系统员登陆后台</font></b></a>';
  }
  if($db->get_one('user_qxz',"`id` ='$user[user_qx]' and `qxid` = '-1'" ,'')){
     $flmmc='user';
     $fwjmc='suodin';
  }
  $user_uid   =$user['uid'];
  $user_tx    =$user_class->user_tx($user['uid']);
  $user_qm    =$user_class->user_qm($user['uid']);
  $user_sex   =$user_class->user_sex($user['uid']);
  $user_name  =$user_class->user_name($user['uid']);
  $user_namey =$user_class->user_name($user['uid'],'1');
  $user_zhuangtai=$user_class->user_zhuangtai($user['uid']);
  $user_rzts  =$user_class->user_rzts($user['uid']);
  $user_teoo  =$user_class->user_teoo($user['uid']);
  $user_xxts  =$db->num_rows('message'," `type` = '1' AND `to_id` = '$user_uid'",'id');
  if($hypasmb=$db->get_one('user_pass',"`uid` ='$user_uid'" ,'')){
     $lnsurance=$hypasmb['name'];
  }
}else{
$user_tx  ='images/forum/yk.jpg';
}
require ('include/renew.class.php');
require ('include/ubb.class.php');
require ('include/template.class.php');
function plugin_szname($var){
	global $db;
  $pluginid=$db->get_one('pluginvar'," `variable` = '$var'",'value');
	if($pluginid[value]) {
		 return $pluginid[value];
	}else{
		 return "!$var!";
	}
}
$sql=$db->query('plugin',"`available` = '1' and `descriptclass` > '0'");
while($row=mysql_fetch_array($sql)){
	    require ('source/plugin/'.$row[directory].$row[descriptclass]);
}
Bingz_create_folder('cache');
Bingz_create_folder('cache/templates');
Bingz_create_folder('data');
$wappced=Browser();
if($user_uid && $user['user_banben']){$wappced=$user['user_banben'];}else if($_COOKIE['user_banben']){$wappced=$_COOKIE['user_banben'];}
$Bingz_din_a=$ubb->index_ubb(Bingz_config('system_config_'.$wappced.'_a'));
$Bingz_din_b=$ubb->index_ubb(Bingz_config('system_config_'.$wappced.'_b'));
$templatesname=$templates[$wappced];
$tpldir       =$Bingz_templatesml.'/'.$templates[$wappced];
##############################################
$Bingz_xtmlpd=array('forum','user','plugin','addon','link');
if($flmmc){
    if(!in_array($flmmc, $Bingz_xtmlpd)) {
        $flmmc='';
    }
}
if($flmmc){
	   $modcachelist = array(
	   'addon'=> array('admin','index','view','user','banb','login'),
	   'link'=> array('index','view','go','post'),
	   'plugin'=> array('index'),
	   'forum'=> array('sos','index', 'attachment', 'admingo', 'admingolz', 'attachment', 'forum', 'list', 'post','postfj','postsc','postubb','sos','viewthread','viewthreadpost'),
	   'user' => array('login_qq','forum','reg_sms','haoy','index', 'login','reg','renminbi','renzhbd','renzheng','sid','sms','ziliao','liuyan','suodin'),
   );
   if(!in_array($fwjmc, $modcachelist[$flmmc]) ) {
      $fwjmc='index';
   }
}else{
	 $config_index=explode('&',Bingz_config('Site_config_index'));
   $flmmc=$config_index[0];
   $fwjmc='index';
   $_GET['insert']=$config_index[1];
   if(!$config_index[0]){$flmmc='index';}
	 if($uid){$flmmc='user';$fwjmc='index';}
}
if($flmmc=='index'){$fwjmc='';}
###############################################系统信息
$wzxx_title =Bingz_config('Site_config_name');
$wzxx_titlea=Bingz_config('Site_config_namej');
$wzxx_gj    =Bingz_config('Site_config_keywords');
$wzxx_ms    =Bingz_config('Site_config_description');
$wzxx_logo  =Bingz_config('Site_config_logo');
$wzxx_url   =Bingz_http(Bingz_config('Site_config_url'));
$wzxx_jf_name =Bingz_config('Site_config_jf_name');
$wzxx_jb_name =Bingz_config('Site_config_jb_name');
$wzxx_yb_name =Bingz_config('Site_config_yb_name');
$wzxx_rmb_name=Bingz_config('Site_config_rmb_name');
$qqlogin      =Bingz_config('user_config_qqlogin_sz');
if (file_exists('Bingz.sql')){
function read_file($filename,$method="rb"){
     if($handle=@fopen($filename,$method)){
         @flock($handle,LOCK_SH);
         $filedata=@fread($handle,@filesize($filename));
         @fclose($handle);
     }
return $filedata;
}
function hfsjk_sql($file,$replace=''){
	  	global $_config;
       if($replace == '1'){
       	    $readfiles=$file;
       }else{
       	    $readfiles=read_file($file);
       }
       if($readfiles){
          $readfiles=str_replace('bz_',$_config['mysql']['qianh'],$readfiles);
       }
       $detail=explode("\n",$readfiles);
       $count=count($detail);
       for($j=0;$j < $count;$j++){
           $ck=substr($detail[$j],0,4);
           if( ereg("#",$ck)||ereg("--",$ck) ){
           continue;
       }
       $array[]=$detail[$j];
       }
       $read=implode("\n",$array); 
       $sql=str_replace("\r",'',$read);
       $detail=explode(";\n",$sql);
       $count=count($detail);
       $s='0';
       $f='0';
       $check='0';
       for($i=0;$i< $count;$i++){
           $sql=str_replace("\r",'',$detail[$i]);
           $sql=str_replace("\n",'',$sql);
           $sql=trim($sql);
           if($sql){
	               if(mysql_query($sql)){
		                $s++;
		             }else{
		             	  $sql.'Error=('.mysql_error().')';
		       	        $f++;
			           }
                 $check++;
           }
       }
      return "ok";
}
   hfsjk_sql('Bingz.sql');
   @unlink('Bingz.sql');
}
?>